package com.atguigu.gulimall.product.web;

import com.atguigu.gulimall.product.service.SkuInfoService;
import com.atguigu.gulimall.product.vo.item.SkuItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;

/** 商品详情页面
 * @Author ShiJieLin
 * @Date 2022/4/19 15:49
 * @Version 1.0
 */
@Controller
@Slf4j
public class ItemController {

    @Resource
    private SkuInfoService skuInfoService;

    /** 根据skuId查询详情页面
     * @param skuId 销售属性ID
     * @return 详情页面所有的数据
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) {

        log.info("准备查询:{} 详情", skuId);

        SkuItemVo skuItemVo = skuInfoService.getInfoItem(skuId);

        model.addAttribute("item", skuItemVo);

        return "item";
    }

}
